From 04662cb9799a1190b18da71ed793f063fbf22f59 Mon Sep 17 00:00:00 2001 From: tsteven4 Date: Sun, 18 Aug 2013 23:34:32 +0000 Subject: [PATCH] tweak datetime operator overload. --- gpsbabel/gopal.cc | 1 - gpsbabel/src/core/datetime.h | 9 ++++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/gpsbabel/gopal.cc b/gpsbabel/gopal.cc index 238817b12..a0bd6522c 100644 --- a/gpsbabel/gopal.cc +++ b/gpsbabel/gopal.cc @@ -295,7 +295,6 @@ gopal_read(void) fatal("Bad date '%s'.\n", c); } wpt->creation_time += mkgmtime(&tm2); - wpt->creation_time = wpt->creation_time.addMSecs(millisecs); break; case 10: // Unknown. Ignored. case 11: // Bearing. Ignored. diff --git a/gpsbabel/src/core/datetime.h b/gpsbabel/src/core/datetime.h index 2ffd7c052..c2d8fdb98 100644 --- a/gpsbabel/src/core/datetime.h +++ b/gpsbabel/src/core/datetime.h @@ -46,9 +46,12 @@ public: DateTime(QDateTime dt) : QDateTime(dt) {} // TODO: this should go away in favor of .addSecs(). - time_t operator+=(const time_t& t) { - setTime_t(toTime_t() + t); - return toTime_t(); + // add time_t without losing any existing milliseconds. + DateTime& operator+=(const time_t& t) { + QDateTime dt = addSecs(t); + setDate(dt.date()); + setTime(dt.time()); + return *this; } // Integer form: YYMMDD -- 2.30.2